import { request } from '@/utils/request';
import CRUD from '@/utils/request/CRUD';
export interface JobVO {
  id: number
  name: string
  status: number
  handlerName: string
  handlerParam: string
  cronExpression: string
  retryCount: number
  retryInterval: number
  monitorTimeout: number
  createTime: Date
}
//定时任务CRUD
export const infraJobCRUD = CRUD('/infra/job');

// 更新定时任务的状态
export function infraJobUpdateStatus(params: Record<string, any>) {
  return request.put({
    url: '/infra/job/update-status?id=' + params.id +'&status='+params.status,
  });
}
//  定时任务立即执行一次
export function runJob(id: number) {
  return request.put({
    url: '/infra/job/trigger?id=' + id,
  });
}

// 获得定时任务的下 n 次执行时间
export function getJobNextTimes(params: Record<string, any>) {
  return request.get({
    url: '/infra/job/get_next_times',
    params,
  });
}
